<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- <link rel="stylesheet" href="style.css" /> -->
    <title>Form Input Wave</title>
  </head>
  <body>
    <div class="container">
      <h1>请注册</h1>
      <form>
        <label id="biaoq">用户名</label>
        <div class="form-control">
          <input type="text" required placeholder="Username" id="nameId">
        </div>
        <label>密码</label>
        <div class="form-control">
          <input type="password" required placeholder="Password" id="passId">
        </div>
        <label>确认密码</label>
        <div class="form-control">
          <input type="password" required placeholder="Confirm password" id="conId">
        </div>
        <label>性别</label>
        <br>
        <br>
        <label>
          <input type="radio" id="sexnanId" value="男" name="sex"/>男
          <input type="radio" id="sexnvId" value="女" name="sex"/>女</label> 
        <br>
        <br>
        <label>电话</label>
        <div class="form-control">
          <input type="text" required placeholder="Telephone" id="telId">
        </div>
        <label>邮箱</label>
        <div class="form-control">
          <input type="text" required placeholder="Email" id="emailId">
        </div>
        <!-- user.setUsername("lisi");
        user.setPassword("123456");
        user.setSex("男");
        user.setTelephone("13906657151");
        user.seteMail("1193162247@qq.com"); -->
        

        <button id="btn-reg" type="reset">注册</button>

        <p class="text">已有账号? <a href="#">登录</a> </p>
      </form>

    </div>
    <style>
      * {
  box-sizing: border-box;
}

body {
  background-color: steelblue;
  color: #fff;
  font-family: 'Muli', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.container {
  background-color: rgba(0, 0, 0, 0.4);
  padding: 20px 40px;
  border-radius: 5px;
}

.container h1 {
  text-align: center;
  margin-bottom: 30px;
}

.container a {
  text-decoration: none;
  color: lightblue;
}

.btn {
  cursor: pointer;
  display: inline-block;
  width: 100%;
  background: lightblue;
  padding: 15px;
  font-family: inherit;
  font-size: 16px;
  border: 0;
  border-radius: 5px;
}

.btn:focus {
  outline: 0;
}

.btn:active {
  transform: scale(0.98);
}

.text {
  margin-top: 30px;
}

.form-control {
  position: relative;
  margin: 20px 0 40px;
  width: 300px;
}

.form-control input {
  background-color: transparent;
  border: 0;
  border-bottom: 2px #fff solid;
  display: block;
  width: 100%;
  padding: 15px 0;
  font-size: 18px;
  color: #fff;
}

.form-control input:focus,
.form-control input:valid {
  outline: 0;
  border-bottom-color: lightblue;
}

.form-control label {
  position: absolute;
  top: 15px;
  left: 0;
  pointer-events: none;
}

.form-control label span {
  display: inline-block;
  font-size: 18px;
  min-width: 5px;
  transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.form-control input:focus + label span,
.form-control input:valid + label span {
  color: lightblue;
  transform: translateY(-30px);
}

    </style>
    <!-- <script src="script.js"></script> -->
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  </body>
</html>

<!-- user.setUsername("lisi");
        user.setPassword("123456");
        user.setSex("男");
        user.setTelephone("13906657151");
        user.seteMail("1193162247@qq.com"); -->
        

<script>
  // <!-- 获取立即注册按钮并绑定点击事件-->
    $("#btn-reg").click(function (){
     console.log($("#nameId").val())
     console.log($("#passId").val())
     console.log($("#conId").val())
     console.log($("input[name='sex']:checked").val())
     console.log($("#telId").val())
     console.log($("#emailId").val())
     if($("#nameId").val() == "" || $("#passId").val() == "" || $("#conId").val() == "" || $("#sexId").val() == "" || $("#telId").val() == "" || $("#emailId").val() == ""){
      alert("请输入完整的信息注册")
     }else if($("#passId").val() != $("#conId").val()){
      alert("请输入正确的确认密码")
     }else{
     // 发送ajax请求到服务端进行注册
      $.ajax({
       url: "http://192.168.96.109:8060/user/reg", //请求地址
       type: "POST", //请求方法
       data: {  //请求传递的参数
        username: $("#nameId").val(),
        password: $("#passId").val(),
        sex:$("input[name='sex']:checked").val(),
        telephone: $("#telId").val(),
        eMail: $("#emailId").val(),
       },
       dataType: "json", //返回类型
       success: function (res){ //请求成功调函数
        console.log(res)
        if(res.state ==200){
         alert("注册成功")
        }else{
         alert(res.message)
        }
       }
      })
     }
    })
  </script>        